﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using static MyGreedySnake.Direction;

namespace MyGreedySnake
{
    internal class BasicBlock : PictureBox
    {
        int x = 0;
        int y = 0;
        const int width = 20;
        const int height = 20;   
        public MDirection direction = MDirection.right; 
        public BasicBlock(int x,int y,Image image)
        {
            this.x = x;
            this.y = y;
            Location = new System.Drawing.Point(x, y);
            Size = new System.Drawing.Size(width, height);
            this.BackgroundImage = image;
            this.BackgroundImageLayout = ImageLayout.Stretch;
            this.BackColor = Color.Transparent;
            this.ForeColor = Color.White;     
        }

        public void setDirection(MDirection dir)
        {
            this.direction = dir;
        }

        public void move()
        {
            switch(this.direction)
            {
                case MDirection.left:
                    this.x = x - 20;
                    this.Location = new System.Drawing.Point(x, y);
                    break;
                case MDirection.right:
                    this.x = x + 20;
                    this.Location = new System.Drawing.Point(x, y);
                    break;
                case MDirection.up:
                    this.y = y - 20;
                    this.Location = new System.Drawing.Point(x, y);
                    break;
                case MDirection.down:
                    this.y = y + 20;
                    this.Location = new System.Drawing.Point(x, y);
                    break;
                default:
                    break;
            }
        }
    }
}
